package com.suneast.suneaststore.modules.personal.wallet.bankcard.adapter;

import android.graphics.Color;
import android.graphics.drawable.GradientDrawable;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.suneast.suneaststore.R;
import com.suneast.suneaststore.bean.personal.bank.BankCardBean;

public class BankCardListAdapter extends BaseQuickAdapter<BankCardBean, BankCardListAdapter.VH> {

    public BankCardListAdapter(int layoutResId) {
        super(layoutResId);
    }

    @Override
    protected void convert(VH helper, BankCardBean item) {
        Glide.with(helper.itemView.getContext()).load(item.getPicture())
                .into((ImageView) helper.getView(R.id.img_bank_icon));
        helper.setText(R.id.tv_bank_name, item.getBankName())
                .setText(R.id.tv_bank_type, item.getBackType() == 1 ?
                        helper.itemView.getContext().getString(R.string.deposit_card) :
                        helper.itemView.getContext().getString(R.string.credit_card))
                .setText(R.id.tv_card_number, item.getNum());
        GradientDrawable gd = new GradientDrawable();//创建drawable
        gd.setColor(Color.parseColor(item.getColor()));
        gd.setCornerRadius(10f);
        View v = helper.getView(R.id.layout_item_bank_card);
        v.setBackground(gd);
    }

    public static class VH extends BaseViewHolder {
        public VH(View view) {
            super(view);
        }
    }
}
